import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:x_project/res/string_res/str_res_keys.dart';

Future loading(Function block, {bool isShowLoading = true}) async {
  if (isShowLoading) {
    showLoading();
  }
  try {
    await block();
  } catch (e) {
    rethrow;
  } finally {
    dismissLoading();
  }
  return;
}

void showLoading() {
  EasyLoading.show(status: SR.processingText.tr);
}

void dismissLoading() {
  EasyLoading.dismiss();
}
